<?php
// ------------------------------------------------------------------
// NEEDED STUBS FOR THIS EXAMPLE
// ------------------------------------------------------------------


// this will include all needed files to be able to build a Request
include_once($CONF["STUBS_FOLDER"]."Map24MapletRemoteControl/Map24MapletRemoteControl.php5");


// ------------------------------------------------------------------
// NEEDED PARAMETERS FOR THIS REQUEST
// ------------------------------------------------------------------


// coordinates of the polygon to add
$longitudes 	= "596.3|598.3|600.3|598.3";
$latitudes 	= "3213.0068|3216.0068|3213.0068|3210.0068";

// the color of the polygon
$Color['red'] = 0;
$Color['green'] = 0;
$Color['blue'] = 255;
$Color['alpha'] = 150;

// zoomlevel
$mapViewClippingWidth = 1000;
$mapViewPercentage = 20;

// discription
$discription = "Polygon-Hamburg";


// definition of the FILL Paint Rule
$FillPaintRule = new PaintRuleFILL();
$FillPaintRule->MaxMPP=100000;
$FillPaintRule->DrawPhase="AREAS";

//first detail
$objIdx=0;
$FillPaintRule->Details[$objIdx]= new PaintRuleFILLDetails();
$FillPaintRule->Details[$objIdx]->MinMPP = 100;
$FillPaintRule->Details[$objIdx]->Color = new Color();
$FillPaintRule->Details[$objIdx]->Color->red = 255;
$FillPaintRule->Details[$objIdx]->Color->green = 0;
$FillPaintRule->Details[$objIdx]->Color->blue = 0;
$FillPaintRule->Details[$objIdx]->Color->alpha = 255;

//another detail
$objIdx++;
$FillPaintRule->Details[$objIdx]=new PaintRuleFILLDetails();
$FillPaintRule->Details[$objIdx]->MinMPP=50;
$FillPaintRule->Details[$objIdx]->Color=new Color();
$FillPaintRule->Details[$objIdx]->Color->red=205;
$FillPaintRule->Details[$objIdx]->Color->green=0;
$FillPaintRule->Details[$objIdx]->Color->blue=50;
$FillPaintRule->Details[$objIdx]->Color->alpha=175;

//another detail
$objIdx++;
$FillPaintRule->Details[$objIdx]=new PaintRuleFILLDetails();
$FillPaintRule->Details[$objIdx]->MinMPP=0;
$FillPaintRule->Details[$objIdx]->Color=new Color();
$FillPaintRule->Details[$objIdx]->Color->red=155;
$FillPaintRule->Details[$objIdx]->Color->green=0;
$FillPaintRule->Details[$objIdx]->Color->blue=100;
$FillPaintRule->Details[$objIdx]->Color->alpha=100;

// definition of the STROKE Paint Rule
$objIdx=0;
$StrokePaintRule = new PaintRuleSTROKE();
$StrokePaintRule->MaxMPP=300;
$StrokePaintRule->DrawPhase="AREAS";

// first detail
$objIdx++;
$StrokePaintRule->Details[$objIdx]= new PaintRuleSTROKEDetails();
$StrokePaintRule->Details[$objIdx]->MinMPP=100;
$StrokePaintRule->Details[$objIdx]->Width=8;
$StrokePaintRule->Details[$objIdx]->Color= new Color();
$StrokePaintRule->Details[$objIdx]->Color->red=0;
$StrokePaintRule->Details[$objIdx]->Color->green=205;
$StrokePaintRule->Details[$objIdx]->Color->blue=50;
$StrokePaintRule->Details[$objIdx]->Color->alpha=125;

// another detail
$objIdx++;
$StrokePaintRule->Details[$objIdx]= new PaintRuleSTROKEDetails();
$StrokePaintRule->Details[$objIdx]->MinMPP=50;
$StrokePaintRule->Details[$objIdx]->Width=14;
$StrokePaintRule->Details[$objIdx]->Color= new Color();
$StrokePaintRule->Details[$objIdx]->Color->red=0;
$StrokePaintRule->Details[$objIdx]->Color->green=205;
$StrokePaintRule->Details[$objIdx]->Color->blue=50;
$StrokePaintRule->Details[$objIdx]->Color->alpha=175;

// another detail
$objIdx++;
$StrokePaintRule->Details[$objIdx]= new PaintRuleSTROKEDetails();
$StrokePaintRule->Details[$objIdx]->MinMPP=0;
$StrokePaintRule->Details[$objIdx]->Width=20;
$StrokePaintRule->Details[$objIdx]->Color= new Color();
$StrokePaintRule->Details[$objIdx]->Color->red=0;
$StrokePaintRule->Details[$objIdx]->Color->green=205;
$StrokePaintRule->Details[$objIdx]->Color->blue=50;
$StrokePaintRule->Details[$objIdx]->Color->alpha=255;


// ------------------------------------------------------------------
// BUILDING THE REQUEST
// ------------------------------------------------------------------


// here are all commands defined and are put together in one ArrayOfCommands

// this object will add a new location
$cmdIdx=0;
$commands[$cmdIdx] = new XMLCommandWrapper();
$commands[$cmdIdx]->DeclareMap24Polygon = new DeclareMap24Polygon();
$commands[$cmdIdx]->DeclareMap24Polygon->MapObjectID = "polygon";
$commands[$cmdIdx]->DeclareMap24Polygon->Coordinates = new CoordinatesArray();
$commands[$cmdIdx]->DeclareMap24Polygon->Coordinates->Longitudes = $longitudes;
$commands[$cmdIdx]->DeclareMap24Polygon->Coordinates->Latitudes = $latitudes;
$commands[$cmdIdx]->DeclareMap24Polygon->FillColor = new Color();
$commands[$cmdIdx]->DeclareMap24Polygon->FillColor->red = $Color['red'];
$commands[$cmdIdx]->DeclareMap24Polygon->FillColor->green = $Color['green'];
$commands[$cmdIdx]->DeclareMap24Polygon->FillColor->blue = $Color['blue'];
$commands[$cmdIdx]->DeclareMap24Polygon->FillColor->alpha = $Color['alpha'];
$commands[$cmdIdx]->DeclareMap24Polygon->Description = $discription;
//add the FillPaintRules
$commands[$cmdIdx]->DeclareMap24Polygon->FillPaintRules=array($FillPaintRule);
//add the StrokePaintRules
$commands[$cmdIdx]->DeclareMap24Polygon->StrokePaintRules=array($StrokePaintRule);

// this object will enable the polygon on the map
$cmdIdx++;
$commands[$cmdIdx] = new XMLCommandWrapper();
$commands[$cmdIdx]->ControlMapObject = new ControlMapObject();
$commands[$cmdIdx]->ControlMapObject->Control = "SHOW";
$commands[$cmdIdx]->ControlMapObject->MapObjectIDs = array("polygon");

// this object will center the map above the polygon
$cmdIdx++;
$commands[$cmdIdx] = new XMLCommandWrapper();
$commands[$cmdIdx]->SetMapView = new SetMapView();
$commands[$cmdIdx]->SetMapView->MapObjectIDs = array("polygon");
$commands[$cmdIdx]->SetMapView->ClippingWidth = new SetMapViewClippingWidth();
$commands[$cmdIdx]->SetMapView->ClippingWidth->MinimumWidth = $mapViewClippingWidth;
$commands[$cmdIdx]->SetMapView->ClippingWidth->ViewPercentage = $mapViewPercentage;

// definition of the request header with Map24ID and SessionID
$header = new RequestHeader();
$header->Map24ID  = $CONF['MAP24_ID'];
$header->ClientID = $CONF['SESSION_ID'];

// definition of the request body
$request = new MapletRemoteControlRequest();
$request->Map24MRC = new Map24MRC();
$request->Map24MRC->Commands = $commands;


// ------------------------------------------------------------------
// EXECUTE THE REQUEST
// ------------------------------------------------------------------
// in this object the SoapClient will be initiated and executed


$mrc = new Map24MapletRemoteControl($CONF['MAPTP_SYSTEM'],$CONF['MAP24_ID'],$CONF['SESSION_ID']);
$response = $mrc->mapletRemoteControl($header,$request);


// ------------------------------------------------------------------
// OUTPUT THE RESULT
// ------------------------------------------------------------------


$resultString = "This command generates no output";
$counter = 0;


?>